﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace StuManDAL.Common
{
    public class DataValidate
    {
        private static DataValidate _instance;

        public static DataValidate Instance
        {
            get
            {
                if (_instance==null)
                {
                    _instance = new DataValidate();
                }
                return _instance;
            }
        }
        private DataValidate()
        {
        }
        private bool CommonMethod(string regularExpression,string txt)
        {
            Regex regex = new Regex(regularExpression);
            return regex.IsMatch(txt);
        }
        public bool IsPositiveInteger(string txt)
        {
            return  CommonMethod(@"^[1-9]\d*$", txt);
        }
        public bool IsIdentityCard(string txt)
        {
            return CommonMethod(@"^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$", txt);
        }
    }
}
